//
// Created by ultcrt on 2021/5/21.
//

#include "hardware_alert.h"

Color HardwareAlert::string2color(const std::string& color) {
    if(color == "black") return Color::black;
    if(color == "red") return Color::red;
    if(color == "green") return Color::green;
    if(color == "blue") return Color::blue;
    if(color == "yellow") return Color::yellow;
    if(color == "purple") return Color::purple;
    if(color == "cyan") return Color::cyan;
    if(color == "white") return Color::white;
    else return Color::black;
}

void HardwareAlert::set(Color color, bool buzzer_on, bool vibrator_on) {
    light.rgb_switch(color);

    if (buzzer_on) buzzer.run();
    else buzzer.stop();

    if (vibrator_on) vibrator.run();
    else vibrator.stop();
}

HardwareAlert::HardwareAlert():
light(18, 37, 38, 40, 1000, 5),
buzzer(13, 1000, 5),
vibrator(15, 1000, 5){}
